package objects.test;

import objects.base.Collidable;
import util.level.Room;

/**
 * A class defining a platform that pushes all
 * who stand upon it in a certain direction
 * 
 * @author John
 */

public class Conveyor extends Collidable
{
	protected float conveyorSpeed;
	
	/**
	 * Initializes a conveyor belt of given size at the given position.
	 * 
	 * @param initX - The initial X position.
	 * @param initY - The initial Y position.
	 * @param initWidth - The initial width of the object.
	 * @param initHeight - The initial height of the object.
	 * @param initSpeed - The speed at which the conveyor belt moves things.
	 */
	public Conveyor(float initX, float initY, float initWidth, float initHeight, float initSpeed)
	{
		super(initX, initY, initWidth, initHeight);
		// Set the conveyor belt's speed
		conveyorSpeed = initSpeed;
		pushPriority = 6;
	}

	/**
	 * All objects on top of the conveyor belt get
	 * carried in the conveyor's direction.
	 * 
	 * @otherObj {@inheritDoc}
	 */
	protected void collision(Room room,Collidable otherObj)
	{
		// If the object is above the conveyor belt and it can be carried
		if (otherObj.getY()+otherObj.getHeight() <= y && otherObj.hasInertia())
		{
			// Move the object on the conveyor
			otherObj.doMotion(room,conveyorSpeed,0);
		}
	}
}
